package roma.lab1;

import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.Toast;
import android.widget.ToggleButton;

public class SettingsActivity extends Activity {

	private ToggleButton toggle;
	private SharedPreferences pref;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.settings);

		toggle = (ToggleButton) findViewById(R.id.toggleButton1);
		
		toggle.setOnCheckedChangeListener(new ModeListener());
	}


	private class ModeListener implements OnCheckedChangeListener{
		public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
			pref = getSharedPreferences("romaexchange", 0);
			SharedPreferences.Editor editor = pref.edit();
			editor.putBoolean("online", isChecked);
			editor.commit();
		}
	}


	@Override
	protected void onStart() {
		super.onStart();
		pref = getSharedPreferences("romaexchange", 0);
		toggle.setChecked(pref.getBoolean("online", true));
	}
	
	
	
	
}
